<template>
    <div>
      <div id="echart1" style="width:600px;height:400px;"></div>
      <div id="echart2" style="width:600px;height:400px;"></div>
    </div>
</template>
<script>
import * as echarts from 'echarts';
import {queryWendu,queryGoodsByType} from '../api/data.js'
export default{
    name:'page3',
    data(){
      return{
        week:[],
        temp:[],
        result:[],
        resultFushi:[],
        fushiName:[],
        fushiNum:[]
      }
    },
    mounted() {
      queryWendu().then(res=>{
        this.result = res.data
        for(var i=0;i<this.result.length;i++){
          this.week.push(this.result[i].week)
          this.temp.push(this.result[i].temp)
        }
        console.log("===处理后的结果==",this.week,this.temp)
        this.initEchart1()
      })
      queryGoodsByType({type:1}).then(res=>{
        console.log("===查询服饰结果==",res)
        this.resultFushi=res.data
        for(var i=0;i<this.result.length;i++){
          this.fushiName.push(this.resultFushi[i].goods)
          this.fushiNum.push(this.resultFushi[i].number)
        }
      })
      this.initEchart2()
      },
      methods:{
        initEchart1(){
          var myChart = echarts.init(document.getElementById('echart1'));
      const option={
            xAxis: {
              type: 'category',
              data: this.week
            },
            yAxis: {
              type: 'value'
            },
            series: [
              {
                data: this.temp,
                type: 'line',
                smooth: true
              }
            ]
          };
      myChart.setOption(option);
        },
        initEchart2(){
          var myChart = echarts.init(document.getElementById('echart2'));
      const option={
  xAxis: {
    type: 'category',
    data: this.fushiName
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: this.fushiNum,
      type: 'bar'
    }
  ]
};
      myChart.setOption(option);
        }
      }
 }
</script>
<style>
</style>